package com.letv.core.bean;

import com.letv.core.utils.LogInfo;

import android.text.TextUtils;

public class LiveStreamBean implements LetvBaseBean {
	/**
	 * STREAM_350:350低码流<p>
	 * STREAM_1000:1000高码流<p>
	 * STREAM_UNKNOWN:未知码流<p>
	 * 
	 * @author zhanglibin
	 * 
	 */
	public enum StreamType {
		STREAM_350, STREAM_1000, STREAM_1300, STREAM_UNKNOWN
	}

	/**
	 * 有350或1000地址的时候忽略未知码流<p>
	 * HAS_STREAM_350_ONLY : 只有350码流地址 <p>
	 * HAS_STREAM_1000_ONLY : 只有1000码流地址 <p>
	 * HAS_STREAM_350_1000_BOTH : 有350和1000码流地址 <p>
	 * HAS_STREAM_UNKNOWN_ONLY : 只有未知码流地址 <p>
	 * HAS_STREAM_NULL : 播放地址liveUrl都为空 <p>
	 * @author zhanglibin
	 * 
	 */
	public enum SupportType {
		HAS_STREAM_350_ONLY, HAS_STREAM_1000_ONLY,HAS_STREAM_1300_ONLY, HAS_STREAM_350_1000_BOTH, HAS_STREAM_UNKNOWN_ONLY, HAS_STREAM_NULL
	}

	private String streamIdUnknown;
	private String liveUrlUnknown;

	private String streamId350;
	private String liveUrl350;

	private String streamId1000;
	private String liveUrl1000;
	
	private String streamId1300;
	private String liveUrl1300;

	private String tm350;
	private String tm1000;
	private String tm1300;
	private String tmUnknown;
	
	private String code350;
	private String code1000;
	private String code1300;
	private String codeUnknown;
	
	private String name;
	private StreamType streamType = StreamType.STREAM_UNKNOWN;// 默认是未知码流

	
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the tm350
	 */
	public String getTm350() {
		return tm350;
	}

	/**
	 * @param tm350 the tm350 to set
	 */
	public void setTm350(String tm350) {
		this.tm350 = tm350;
	}

	/**
	 * @return the tm1000
	 */
	public String getTm1000() {
		return tm1000;
	}

	/**
	 * @param tm1000 the tm1000 to set
	 */
	public void setTm1000(String tm1000) {
		this.tm1000 = tm1000;
	}

	/**
	 * @return the tmUnknown
	 */
	public String getTmUnknown() {
		return tmUnknown;
	}

	/**
	 * @param tmUnknown the tmUnknown to set
	 */
	public void setTmUnknown(String tmUnknown) {
		this.tmUnknown = tmUnknown;
	}

	/**
	 * @return the code350
	 */
	public String getCode350() {
		return code350;
	}

	/**
	 * @param code350 the code350 to set
	 */
	public void setCode350(String code350) {
		this.code350 = code350;
	}

	/**
	 * @return the code1000
	 */
	public String getCode1000() {
		return code1000;
	}

	/**
	 * @param code1000 the code1000 to set
	 */
	public void setCode1000(String code1000) {
		this.code1000 = code1000;
	}

	/**
	 * @return the codeUnknown
	 */
	public String getCodeUnknown() {
		return codeUnknown;
	}

	/**
	 * @param codeUnknown the codeUnknown to set
	 */
	public void setCodeUnknown(String codeUnknown) {
		this.codeUnknown = codeUnknown;
	}

	/**
	 * 设置码流类型，不设置默认为未知码流
	 * 
	 * @param type
	 */
	public void setStreamType(StreamType type) {
		this.streamType = type;
	}

	public String getStreamIdUnknown() {
		return streamIdUnknown;
	}

	public String getLiveUrlUnknown() {
		return liveUrlUnknown;
	}

	public String getStreamId350() {
		return streamId350;
	}

	public String getLiveUrl350() {
		return liveUrl350;
	}

	public String getStreamId1000() {
		return streamId1000;
	}

	public String getLiveUrl1000() {
		return liveUrl1000;
	}

	public StreamType getStreamType() {
		return streamType;
	}

	public void setStreamIdUnknown(String streamIdUnknown) {
		this.streamIdUnknown = streamIdUnknown;
	}

	public void setLiveUrlUnknown(String liveUrlUnknown) {
		this.liveUrlUnknown = liveUrlUnknown;
	}

	public void setStreamId350(String streamId350) {
		this.streamId350 = streamId350;
	}

	public void setLiveUrl350(String liveUrl350) {
		this.liveUrl350 = liveUrl350;
	}

	public void setStreamId1000(String streamId1000) {
		this.streamId1000 = streamId1000;
	}

	public void setLiveUrl1000(String liveUrl1000) {
		this.liveUrl1000 = liveUrl1000;
	}

	public String getStreamId1300() {
		return streamId1300;
	}

	public void setStreamId1300(String streamId1300) {
		this.streamId1300 = streamId1300;
	}

	public String getLiveUrl1300() {
		return liveUrl1300;
	}

	public void setLiveUrl1300(String liveUrl1300) {
		this.liveUrl1300 = liveUrl1300;
	}

	public String getTm1300() {
		return tm1300;
	}

	public void setTm1300(String tm1300) {
		this.tm1300 = tm1300;
	}

	public String getCode1300() {
		return code1300;
	}

	public void setCode1300(String code1300) {
		this.code1300 = code1300;
	}

	/**
	 * 获取都有什么码流地址
	 * @return
	 */
	public SupportType getHasStream() {
		boolean has350 = !TextUtils.isEmpty(liveUrl350);
		boolean has1000 = !TextUtils.isEmpty(liveUrl1000);
		boolean has1300 = !TextUtils.isEmpty(liveUrl1300);
		boolean hasUnknown = !TextUtils.isEmpty(liveUrlUnknown);

		if (has350 && !has1000) {
			return SupportType.HAS_STREAM_350_ONLY;
		} else if (!has350 && has1000) {
			return SupportType.HAS_STREAM_1000_ONLY;
		}else if(!has350&&!has1000&&has1300){
			return SupportType.HAS_STREAM_1300_ONLY;
		}else if (has350 && has1000) {
			return SupportType.HAS_STREAM_350_1000_BOTH;
		} else if (!has350 && !has1000 && hasUnknown) {
			return SupportType.HAS_STREAM_UNKNOWN_ONLY;
		} else {
			return SupportType.HAS_STREAM_NULL;
		}
	}
	/**
	 * 根据所设置的码流类型取对应的码流
	 * @return
	 */
	public String getStreamId() {
		switch (streamType) {
		case STREAM_350:
			return TextUtils.isEmpty(streamId350) ? streamId1000 : streamId350;
		case STREAM_1000:
			return streamId1000;
		case STREAM_1300:
			return streamId1300;
		case STREAM_UNKNOWN:
			return streamIdUnknown;
		default:
			return streamId350;
		}
	}
	/**
	 * 根据所设置的码流类型取对应的码流
	 * @return
	 */
	public String getLiveUrl() {
		LogInfo.log("clf", "getLiveUrl.,,streamType="+streamType);
		switch (streamType) {
		case STREAM_350:
			return TextUtils.isEmpty(liveUrl350) ? liveUrl1000 : liveUrl350;
		case STREAM_1000:
			return liveUrl1000;
		case STREAM_1300:
			return liveUrl1300;
		case STREAM_UNKNOWN:
			return liveUrlUnknown;
		default:
			return liveUrl350;
		}
	}
	
	public String getTm() {
		switch (streamType) {
		case STREAM_350:
			return TextUtils.isEmpty(tm350) ? tm1000 : tm350;
		case STREAM_1000:
			return tm1000;
		case STREAM_1300:
			return tm1300;
		case STREAM_UNKNOWN:
			return tmUnknown;
		default:
			return tm350;
		}
	}
	public String getCode() {
		switch (streamType) {
		case STREAM_350:
			return TextUtils.isEmpty(code350) ? code1000 : code350;
		case STREAM_1000:
			return code1000;
		case STREAM_1300:
			return code1300;
		case STREAM_UNKNOWN:
			return codeUnknown;
		default:
			return code350;
		}
	}
	
	   @Override
	    public String toString() {
	        return getLiveUrl() + ":" + getTm() + this.getCode() + ":" + this.getName() + ":" + this.getStreamId1000();
	    }
}
